package com.vecspace.web;
/**用于在http请求期间，获取HttpRequest HttpResponse对象
 * 
 * @version: 1.0
 * @author: wanghua
 */
public class HttpContextThreadLocal{
	private static ThreadLocal<HttpContext> httpContextThreadLocal = new ThreadLocal<HttpContext>();

	private static ThreadLocal<HttpContext> getHttpContextThreadLocal() {
		if(httpContextThreadLocal.get() == null){
			HttpContext info = new HttpContext();
			httpContextThreadLocal.set(info);
		}
		return httpContextThreadLocal;
	}
	
	/**用于清除线程变量（在有线程池的情况下，必须先remove之后再使用）
	 *   
	 * @author: wanghua
	 */
	public static void remove() {
		if(httpContextThreadLocal != null) {
			httpContextThreadLocal.remove();
		}
	}
 
	
	public static HttpContext getHttpContext(){
		return getHttpContextThreadLocal().get();
	}
}
